package routes

import (
	"github.com/goravel/framework/contracts/route"
	"github.com/goravel/framework/facades"
	"goravel/app/http/controllers"
	"goravel/app/http/middleware"
)

// Middleware(middleware.Jwt()).
func Api() {
	authController := controllers.NewAuthController()
	facades.Route().Post("api/auth/login", authController.Login) //slaver

	facades.Route().Middleware(middleware.Jwt()).Middleware(middleware.OvertimeMiddleware()).Prefix("/api").Group(func(router route.Router) {
		//#region   ====================系统基础==========================
		userController := controllers.NewUserController()

		router.Get("/user/info", userController.Info)     //slaver
		router.Get("/auth/logout", authController.Logout) //slaver
		//ftp控制
		ftpController := controllers.NewFtpController()
		//下载和解析
		router.Get("/ftp/my", ftpController.My)             //slaver
		router.Get("/ftp/history", ftpController.History)   //slaver
		router.Post("/config/ftp/test", ftpController.Test) //master(network)
		router.Post("/ftp", ftpController.Store)            //master
		router.Put("/ftp/:id", ftpController.Update)        //master

		configController := controllers.NewConfigurationController()
		router.Get("/config", configController.Index)       //slaver
		router.Post("/config", configController.Store)      //master
		router.Put("/config/{id}", configController.Update) //master

		//#endregion====================系统基础==========================

		//#region ====================socket缓存用户==========================
		socketController := controllers.NewSocketController()
		router.Post("/socket/cache", socketController.Cache) //slaver
		//#endregion ====================socket缓存用户==========================

		//#region====================解析==========================

		//#endregion====================解析==========================

	})

	//	日志查询:slaver
	facades.Route().Middleware(middleware.Jwt()).Middleware(middleware.OvertimeMiddleware()).Middleware(middleware.ConfigurationMiddleware()).Prefix("/api").Group(func(router route.Router) {
		//#region ====================查询日志==========================
		loginlogController := controllers.NewLoginlogController()
		router.Get("/loginlog", loginlogController.Index)
		//	聊天日志
		chatlogController := controllers.NewChatlogController()
		router.Get("/chatlog", chatlogController.Index)
		//	击杀日志
		killlogController := controllers.NewKilllogController()
		router.Get("/killlog", killlogController.Index)
		//	交易日志
		tradelogController := controllers.NewTradelogController()
		router.Get("/tradelog", tradelogController.Index)
		//	违规日志
		violationlogController := controllers.NewViolationlogController()
		router.Get("/violationlog", violationlogController.Index)
		//	管理员日志
		adminlogController := controllers.NewAdminlogController()
		router.Get("/adminlog", adminlogController.Index)
		//	地雷日志
		minelogController := controllers.NewMinelogController()
		router.Get("/minelog", minelogController.Index)
		//	银行日志
		banklogController := controllers.NewBanklogController()
		router.Get("/banklog", banklogController.Index)
		//	领地棋日志
		landflaglogController := controllers.NewLandflaglogController()
		router.Get("/flaglog", landflaglogController.Index)

		prylocklogController := controllers.NewPrylocklogController()
		router.Get("/prylocklog", prylocklogController.Index)

		materialController := controllers.NewMaterialController()
		router.Get("/material", materialController.Index)
		//#endregion ====================查询日志=======================

		//#region ====================网站首页接口==========================
		dashBoardController := controllers.NewDashboardController()
		router.Get("/dashboard", dashBoardController.Index)
		router.Get("/statistics_player", dashBoardController.StatisticsPlayer)
		historyPlayerController := controllers.NewHistoryplayerController()
		router.Get("/history_player", historyPlayerController.Index)
		router.Get("/history_login_player", historyPlayerController.PlayerLoginHistory)
		//#endregion ====================网站首页接口==========================
	})

	//管理员操作
	facades.Route().Middleware(middleware.Jwt()).Middleware(middleware.AdminMiddleware()).Prefix("/api").Group(func(router route.Router) {
		//	修改用户密码
		userController := controllers.NewUserController()
		router.Post("/user/{id}/update_pass", userController.UpdatePassword) //master
		//#region ====================充值==========================
		refillcardController := controllers.NewRefillcardController()
		router.Get("/refillcard", refillcardController.Index) //slaver
		// 批量生成充值卡
		router.Post("/refillcard/generate", refillcardController.BatchCreate) //slaver
		router.Post("user/{id}/charge", refillcardController.Charge)          //master
		//	#endregion ====================充值==========================

		//#region ====================充值订单==========================
		orderController := controllers.NewOrderController()
		router.Get("/order", orderController.Index)              //slaver
		router.Get("user/{id}/order", orderController.UserOrder) //slaver
		//#endregion ====================充值订单==========================

		//#region ====================用户管理==========================

		router.Get("/user", userController.Index)           //slaver
		router.Get("/user/{id}", userController.Show)       //slaver
		router.Delete("/user/{id}", userController.Destroy) //master
		//#endregion ====================用户管理==========================
		//#region ====================登录日志==========================
		logController := controllers.NewLogController()
		router.Get("/log", logController.Index) //slaver
		//#endregion ====================登录日志==========================

	})

	//grpc服务
	facades.Route().Middleware(middleware.Jwt()).Prefix("/grpc").Group(func(router route.Router) {
		//注册
		facades.Route().Post("api/auth/register", authController.Register) //master
		facades.Route().Post("api/auth/charge", authController.Charge)     //master
	})
}
